import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AuthService } from '../services/auth.service';

/**
 * 权限处理
 */
@Injectable()
export class PermissionsResolve implements Resolve<any> {
    constructor(private router: Router, private _authService: AuthService) {}

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        // let url = '';
        // if (state.url.includes('?')) {
        //     url = state.url.substring(0, state.url.lastIndexOf('?'));
        // } else {
        //     url = state.url;
        // }
        //
        // return this._authService.getUserButtonPermission(url).pipe(
        //     map((res) => {
        //         if (res.code === 200) {
        //             return res.data;
        //         }
        //     })
        // );
        // return [''];
    }
}
